package com.yixq.service;

import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yixq.util.HttpClientUtil;
import com.yixq.vo.AssetRequestVo;
import com.yixq.vo.DataRequestVo;
import com.yixq.vo.DataResponseVo;
import com.yixq.vo.FkBackRequestVo;

public class HttpRequestService {
	
	private static Logger logger = LoggerFactory.getLogger(HttpRequestService.class); 

	
	public static String getRequestStatus(String assetID, DataResponseVo vo) {
		AssetRequestVo requestVo = new AssetRequestVo();
		DataRequestVo dataVo = new DataRequestVo();
		dataVo.setAssetID(assetID);
		requestVo.setData(dataVo);
		String url="http://112.74.170.114:18082/HXYL_Fund_Api/Fuyin/asset_status";
		// 发送 POST 请求
		//String sr = sendPost("http://112.74.170.114:18082/HXYL_Fund_Api/Fuyin/asset_status",JSONObject.toJSONString(requestVo));
		String sr=HttpClientUtil.sendPost(url,JSONObject.parseObject(JSONObject.toJSONString(requestVo)));
		vo.setResponse(sr);
		JSONObject json = JSONObject.parseObject(sr);
		if(null==json||null==json.getString("code")||!json.getString("code").equals("1")){
			return "-100";
		}
		JSONArray jsonarray = json.getJSONArray("data");
		if (null==jsonarray|| jsonarray.size()== 0) {
			return "-100";
		}
		JSONObject data = jsonarray.getJSONObject(0);
		if (null == data && null == data.getString("AssetStatus")) {
			return "-100";
		}
		return data.getString("AssetStatus");
		
	}
	
	
	public static String getRequestFkBackDD(FkBackRequestVo requestVo,Map<String,Object> reqMap) {
		String url="http://10.32.1.3:8081/hkd_fk/backDD";
		String sr="";
		try {
			//sr = HttpClientUtil.sendGet(url, reqMap);
			
			sr = HttpClientUtil.sendPost(url, reqMap);
		} catch (Exception e) {
			logger.error("",e);
		}
		
		return sr;
	}
}
